home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 3
/
Cream of the Crop 3.iso
/
clipper
/
ks94an.zip
/
ISAVERAG.HDR
< prev
next >
Wrap
Text File
|
1994-04-25
|
3KB
|
86 lines
/******************************************************************************
The Klipper Library, for CA-Clipper 5.x
Copyright (c), 1994, Wallace Information Systems Engineering
FUNCTION:
_IsAverage( anArray, nRange ) --> nElement
PARAMETERS:
anArray : Array to average and return element from
nRange : 0 = return nearest without EXceeding average
1 = Return nearest (DEFAULT)
2 = Return nearest without PREceeding average
SHORT:
Determine the array element that contains the average value of the array.
DESCRIPTION:
_IsAverage() returns the element number of an array that is or is closest to
the average of the values in the array according to the option specified in
nRange.
If nRange = 0, the element that contains the HIGHEST value BELOW the array
average is returned. That is, the closest value for n < AVERAGE (ie, "who
of the below average group is closest to average?")
If nRange = 1, the element that is closest to the array average is returned,
regardless of whether it is higher, lower or equal to the array average. (ie,
"who of the entire group is closest to the group's average?")
If nRange = 2, the element that contains the LOWEST value ABOVE the array
average is returned. That is, the closest value for n > AVERAGE (ie, "who
of the above average group are closest to average?).
NOTE:
The lowside and highside ranges return the element number that contains the
closest to the average without equaling it.
Thus:
#define LOW 0
#define CLOSEST 1
#define HIGH 2
ar := { 1,2,3,4,5,6,7,8,9 }
The average is 5
The LOW range closest is 4
The HIGH range closest is 6
The CLOSEST range closest is 5 itself, because CLOSEST includes EQUALITY
whereas LOW and HIGH EXCLUDE equality.
EXAMPLE:
#define LOW 0
#define CLOSEST 1
#define HIGH 2
LOCAL anNums1 := { 12.1, 2.2, 7.3, 2.6, 5.9, 6.06, 0.5 } // 5.24
i = _IsAverage(anNums1) // defaults to CLOSEST
Result: The average of the values in anArray is 5.24, so the closest value is
5.9. Therefore, i == 5 because anArray[5] == 5.9.
i = _IsAverage(anNums1,LOW)
Result: The average of the values in anArray is 5.24, so the closest value
without exceeding the average is 2.6. Therefore, i == 4 because anArray[4]
== 2.6
i = _IsAverage(anNums1,HIGH)
Result: The average of the values in anArray is 5.24, so the closest
value without PRECEEDING the average is 5.9. Therefore, i == 4 because
anArray[5] == 5.9
******************************************************************************/